package com.tongji.housediy.view
{
	import com.tongji.housediy.events.commonEvent.ResetRadioGroupEvent;
	import com.tongji.housediy.events.TypeXMLAdminEvent;
	import com.tongji.housediy.view.Building3DComp;
	
	import flash.events.MouseEvent;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 * 
	 * @author chenchao
	 * 
	 */
	public class Building3DCompMediator extends Mediator
	{
		[Inject]
		public var view:Building3DComp;
		
		override public function onRegister():void
		{
			view.lineBtn.addEventListener(MouseEvent.CLICK, lineBtnClickHandler);
			view.wall3DBtn.addEventListener(MouseEvent.CLICK, wall3DBtnClickHandler);
			
			this.addContextListener(ResetRadioGroupEvent.RESET_WALL_RADIO, resetWallRadioHandler, ResetRadioGroupEvent);
		}
		
		private function lineBtnClickHandler(event:MouseEvent):void
		{
			view.myDIYGroup.selection = view.lineBtn;
			dispatch(new TypeXMLAdminEvent(TypeXMLAdminEvent.UPDATE_WALL_LEVEL1_XML, "skirting"));
		}
		
		private function wall3DBtnClickHandler(event:MouseEvent):void
		{
			view.myDIYGroup.selection = view.wall3DBtn;
			dispatch(new TypeXMLAdminEvent(TypeXMLAdminEvent.UPDATE_WALL_LEVEL1_XML, "wall"));
		}
		
		private function resetWallRadioHandler(event:ResetRadioGroupEvent):void
		{
			view.myDIYGroup.selection = view.wall3DBtn;
		}
	}
}